<!--数据字典管理-->
<template>
  <a-modal v-model="showAddTable" :mask-closable="false" :closable="true" :width="1200"
           title="签到列表"
           :maskClosable="false"
           :footer="null"
           :destroyOnClose="true" @cancel="closeModal">
    <sign-statistic :class-t-id="classTId" />
      <a-table style="height: 600px;overflow-y: auto" :columns="columns" :dataSource="signListData" :rowKey="record => record.recordId"
               :pagination="false">
        <span slot="index" slot-scope="text, record, index">
                    {{ index + 1 }}
                </span>
        <span slot="signState" slot-scope="text, record, index" :style="{color:(text === '1'?'#00ff00':'#000000')}">
                    {{ signState[Number(text)].label }}
                </span>

      </a-table>
  </a-modal>
</template>

<script>
import signStatistic from './signStatistic.vue'
export default {
  name: 'signList',
  components: {
    signStatistic
  },
  data () {
    return {
      showAddTable: false,
      classTId: '',
      signListData: [],
      signState:[
        {value:"0",label:"未签到"},
        {value:"1",label:"已签到"}
      ],
      columns: [
        {title: '序号', key: 'index', width: '8%', align: 'center', scopedSlots: {customRender: 'index'}},
        {title: '学生姓名', dataIndex: 'stuName', key: 'stuName', width: '15%'},
        {title: '专业', dataIndex: 'majorName', key: 'majorName'},
        {title: '班级', dataIndex: 'className', key: 'className', width: '25%',},
        {title: '签到状态', dataIndex: 'signState', key: 'signState', width: '15%', scopedSlots: {customRender: 'signState'}},
        {title: '实验桌号', dataIndex: 'diskNum', key: 'diskNum', width: '8%'},

      ],
    }
  },
  computed: {


  },
  filters: {
    filterWord(value, list) {
      for (let i=0; i<list.length; i++) {
        if (value === list[i].value) {
          return list[i].label
        }
      }
    },
  },
  methods: {

    showModal(opt){
      this.classTId = opt.recordId
      this.getSignListData(this.classTId)
    },

    closeModal(){
      this.showAddTable = false
      this.signListData = []
    },

    /**
     * Function    : delRole
     * Description : 批量删除角色
     * Input       : none
     * Return      : none
     */
    getSignListData (classTId) {
      let _this = this
      _this.showAddTable = true
      this.$store.dispatch ('lessonSignListAct', {classTId: classTId}).then (response => {
        if (response.code === 0) {
          _this.signListData = response.data
        } else {
          this.$message.error (response.message)
        }
      })
    },

  },
  created () {
  },
  mounted () {

  }
}
</script>
